#ifndef SCT_DECODE_DECODEINTERFACE_H
#define SCT_DECODE_DECODEINTERFACE_H

#include <stdint.h>
#include "../encode/encodeinterface.h"

namespace sct
{

class CDecodeCallback;
class CDecodeInterface
{
public:
	class CBlockInfo
	{
	public:
        int64_t pts;

		int width;
		int height;

		int nb_samples;
        int sample_rate;
	};

public:
	/**
	 * init the encode library
	 */
	static void initlib();
	/**
	 * create a decoder
	 *
	 * @param name must be 'decode'
	 */
	static CDecodeInterface* create(const char * name, const CodecType codecType);
	virtual ~CDecodeInterface(){}

	/**
	 * init a object
	 *
	 * after call it, the object is ready to decode.
	 */
	virtual void init() {}

    virtual void decode(const void * d, const int len, const int64_t pts) {}

	void addCallback(CDecodeCallback * callback){mCallback = callback;}
	void delCallback(CDecodeCallback * callback){mCallback = NULL;}
protected:
	CDecodeInterface(const CodecType codecType):mCallback(NULL), mCodecType(codecType){}

protected:
	CDecodeCallback* mCallback;
	CodecType mCodecType;
};

class CDecodeCallback
{
public:
    virtual ~CDecodeCallback(){}

	virtual void onGenData(CDecodeInterface* caller,
			const void* buf, const int len,
			const CDecodeInterface::CBlockInfo & info){}
};

}

#endif
